package com.javalab.recorder;

import java.io.File;
import java.util.List;

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.TargetDataLine;

public class Bootstrap {
	public static void main(String[] args) {
		SoundController soundController = new SoundController();
		SoundRecorderUI soundRecorderUI = new SoundRecorderUI();
		List<Mixer.Info> mixerInfoList = soundController.getTargetDataLineMixerInfos();
		Mixer.Info selectedMixerInfo = soundRecorderUI.getSelectedMixerInfo(mixerInfoList);
		TargetDataLine targetDataLine = soundController.getTargetDataLine(selectedMixerInfo);
		AudioFormat audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 44100.0F, 16, 2, 4, 44100.0F, false);
		SoundRecordThread recordThread = new SoundRecordThread(targetDataLine, audioFormat, AudioFileFormat.Type.WAVE, new File("D:/captured.wav"));
		soundRecorderUI.waitingForStartingRecording();
		recordThread.startRecording();
		soundRecorderUI.waitingForStopingRecording();
		recordThread.stopRecording();
	}
}
